// Jest测试环境设置
global.console = {
  ...console,
  // 在测试中禁用某些日志输出
  log: jest.fn(),
  debug: jest.fn(),
  info: jest.fn(),
  warn: console.warn,
  error: console.error,
}

// 模拟浏览器环境API
Object.defineProperty(window, 'performance', {
  value: {
    now: jest.fn(() => Date.now()),
    mark: jest.fn(),
    measure: jest.fn(),
    getEntriesByType: jest.fn(() => []),
    getEntriesByName: jest.fn(() => [])
  }
})

// 模拟localStorage
const localStorageMock = {
  getItem: jest.fn(),
  setItem: jest.fn(),
  removeItem: jest.fn(),
  clear: jest.fn(),
}
global.localStorage = localStorageMock

// 模拟sessionStorage
const sessionStorageMock = {
  getItem: jest.fn(),
  setItem: jest.fn(),
  removeItem: jest.fn(),
  clear: jest.fn(),
}
global.sessionStorage = sessionStorageMock

// 模拟fetch
global.fetch = jest.fn()

// 模拟XMLHttpRequest
global.XMLHttpRequest = jest.fn(() => ({
  open: jest.fn(),
  send: jest.fn(),
  setRequestHeader: jest.fn(),
  addEventListener: jest.fn(),
}))

// 模拟uni-app环境
global.uni = {
  request: jest.fn(),
  onError: jest.fn(),
  onAppHide: jest.fn(),
  onAppShow: jest.fn(),
  getSystemInfoSync: jest.fn(() => ({
    platform: 'h5',
    system: 'iOS 14.0',
    model: 'iPhone',
    windowWidth: 375,
    windowHeight: 667,
    statusBarHeight: 20
  })),
  getPerformance: jest.fn(() => ({
    getEntriesByType: jest.fn(() => []),
    now: jest.fn(() => Date.now())
  })),
  showToast: jest.fn(),
  hideLoading: jest.fn(),
  showLoading: jest.fn()
} 